import Vue from 'vue'
import Vuex from 'vuex'
import pkg from 'package'
import * as actions from './actions'
import * as getters from './getters'

import * as types from './mutation-types'

import app from './modules/app'
import menu from './modules/menu'

Vue.use(Vuex);


const mutations = {
    settoken(state, tk) {
        localStorage.token = tk;
        state.token = tk;
    },
    [types.LOGOUT] (state) {
        localStorage.removeItem('token');
        state.token = null
    },
}

const store = new Vuex.Store({
    strict: true,
    actions,
    getters,
    state: {
        token: localStorage.token,
        pkg
    },
    modules: {
        app,
        menu
    },
    mutations
})

export default store